<?php
namespace Admin\Controller;
//配送范围地图维护
session_start();

use Common\Controller\AdminbaseController;

class DistributionmapController extends AdminbaseController{

	// 列表
	public function index(){
//        session('dismap',null);
	    if(!empty($id = I('get.id',0,'intval'))){

        }
        if(!empty(session('dismap'))){
            $map = session('dismap');
            $this->assign('map',$map);
        }
        $city = array(array('city_id'=>0,'city_name'=>'长宁区'),array('city_id'=>1,'city_name'=>'徐汇区'));
        $this->assign('city',$city);

		$this->display();
	}

	// 添加提交
	public function add_post(){
		if(IS_POST){
		    $date = $_POST;
            $date['id'] = time();
            $map = 'dismap'.$date['id'];
            $_SESSION['dismap']["$map"] = $date;
            $success = array('id'=>$date['id'],'name'=>$date['map_name']);
            $this->ajaxReturn($success);
		}
	}

	// 编辑
	public function edit(){
	    $id = I('post.id',0,'intval');
	    $key = 'dismap'.$id;
        $map = $_SESSION['dismap'][$key];
        $this->ajaxReturn($map);
	}

	// 编辑提交
	public function edit_post(){
		if (IS_POST) {
            $date = $_POST;
            $map = 'dismap'.$date['id'];
            $_SESSION['dismap']["$map"] = $date;
            $success = array('id'=>$date['id'],'name'=>$date['map_name']);
            $this->ajaxReturn($success);
		}
	}

}